package com.wt.util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

/**
 * 配置文件动态加载类
 * @author lidong
 *
 */
public class PropertiesLoad {

	public static Properties prop = new Properties();
	private String windowsPath;//在windows下的配置文件路径
	private String linuxPath;//在linux下的配置文件路径
	
	public PropertiesLoad(String windowsPath,String linuxPath) {
		this.windowsPath = windowsPath;
		this.linuxPath=linuxPath;
		init();
	}
	
	public PropertiesLoad(){
		init();
	}
	/**
	 * 初始化配置文件
	 * @throws FileNotFoundException
	 * @throws IOException
	 */
	public void init() {
		//获取系统类型
		String systemType = System.getProperty("os.name");
		//加载的配置文件路径
		String filePath;
		//如果系统是windows系统，则采用windows的配置地址 如果是linux 就采用linux的配置地址
		if(systemType.toLowerCase().startsWith("win")){
			filePath = windowsPath;
		}else {
			filePath =  linuxPath;
		}
		try {
			prop.load(new FileInputStream(filePath));
		}catch(FileNotFoundException e){
			e.printStackTrace();
		}catch (IOException e) {
			e.printStackTrace();
		}
	}

	
	
	
	
	public String getWindowsPath() {
		return windowsPath;
	}

	public void setWindowsPath(String windowsPath) {
		this.windowsPath = windowsPath;
	}

	public String getLinuxPath() {
		return linuxPath;
	}

	public void setLinuxPath(String linuxPath) {
		this.linuxPath = linuxPath;
	}
}
